<template>
  <div class="session-dialog-container" id="dialogContainer">
    <div class="refresh-item-group">
      <el-link style="font-size: 13px;" :underline="false" type="info">更多记录</el-link>
    </div>
    <div class="message-item" v-for="msg in messages" :key="msg.id">
      <div
        v-if="(type=='visitor' && msg.fromVisitor) || (type=='cs' && !msg.fromVisitor)"
        class="right-session-item-group"
      >
        <div class="session-right-item">
          <div class="right-session-time-style">
            <span v-if="type=='cs'">{{msg.customerServiceId}}号客服</span>
            <span v-else>{{currentSession.visiterName}}</span>
            <span>{{msg.sendTime}}</span>
          </div>
          <div style="margin-top: 20px" class="session-content-style">{{msg.content}}</div>
        </div>
        <el-avatar :size="40" :src="imageUrl"></el-avatar>
      </div>
      <div v-else class="left-session-item-group">
        <el-avatar :size="40" :src="imageUrl"></el-avatar>
        <div class="session-right-item">
          <div class="left-session-time-style">
            <span v-if="type=='visitor'">{{msg.customerServiceId}}号客服</span>
            <span v-else>{{currentSession.visiterName}}</span>
            <span>{{msg.sendTime}}</span>
          </div>
          <div class="session-content-style">{{msg.content}}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "SessionDialog",
  components: {},
  props: {
    messages: Array,
    currentSession: Object,
    type: String
  },
  data() {
    return {};
  },
  watch: {},
  computed: {
    imageUrl() {
      return this.$store.state.imageUrl;
    }
  },
  methods: {},
  created() {},
  mounted() {}
};
</script>

<style scoped>
.session-dialog-container {
  width: 100%;
}
.refresh-item-group {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 50px;
}
.left-session-item-group {
  width: 90%;
  display: flex;
  padding: 10px;
}
.right-session-item-group {
  margin: 10px;
  display: flex;
  float: right;
  clear: both;
}
.session-right-item {
  padding: 0 10px;
}
.left-session-time-style {
  font-size: 13px;
  color: #969696;
  padding-bottom: 5px;
}
.right-session-time-style {
  font-size: 13px;
  color: #969696;
  padding-bottom: 5px;
  float: right;
}
.session-content-style {
  padding: 10px;
  background-color: #fff;
  border-radius: 5px;
  box-shadow: 5px 5px 5px gainsboro;
  max-width: 40vw;
  font-size: 14px;
  color: rgb(71, 71, 71);
}
</style>